<?php

/*
 * Created on 06/07/2007
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
# include("../../db_connect.php");

class HTMLCheckBox {

	var $name;
	var $value;
	var $checked = FALSE;
	var $nColumn;

	function htmlCheckBox() {
		$this->name = "";
		$this->value = "";
		$this->checked = "";
		$this->nColumn="";
	}
	
	
	
	function getHTML($name, $value,  $checked ="" ) {
		$html = "";
		$this->name = $name;
		$this->value = $value;
		$this->checked = $checked;
			$html = "<input type=\"checkbox\" id=\"$name\" name=\"$name\" value=\"$value\"";
			if($this->checked)
				$html .= "checked=\"checked\"";
			$html .= "/>";
			return $html;
	}
	
	function generateFromDB($sql, $prefix){
		$html = "";
		$res = mysql_query($sql);
		$i=1;
		while($row = mysql_fetch_row($res)){
			$cb = new htmlCheckBox();
			$html.= "<tr><td>$row[1]</td> "."<td>".$cb->getHTML($prefix.$i,$row[0],TRUE)."</td></tr>";
			$i++;
		}
		return $html;
	}
	function Render($sql, $prefix){
		$html = "";
		$res = mysql_query($sql);
		$i=1;
		while($row = mysql_fetch_row($res)){
			$cb = new htmlCheckBox();
			$html.= "$row[1] ".$cb->getHTML($prefix.$i,$row[0],TRUE);
			$i++;
		}
		return $html;
	}
	
	function fillfromColumn($rows,$name,$nColumn){
		$html = "";
		//$html.= "<td>".$cb->getHTML($rows[$this->name],$rows[$this->nColumn],FALSE)."</td>";
		$cb = new htmlCheckBox();
		$html.= $cb->getHTML($name,$rows[$nColumn],FALSE);
		return $html;
	}

}

#$cb = new htmlCheckBox();
#echo $cb->generateFromDB("SELECT id, nombre FROM tipos_reservaciones","z");

#print_r($cb);
#echo $cb->getHtml("r1",1,"1",TRUE);
?>
